<script setup lang="ts">
import { onMounted } from 'vue'
import useStoreCategory from '@/store/modules/category.ts'
const storeCategory = useStoreCategory()
const props = defineProps(['screen'])
onMounted(() => {
  getC1()
})
const getC1 = () => {
  storeCategory.getC1()
}
const selectOne = () => {
  storeCategory.c2Id = ''
  storeCategory.c3Arr = []
  storeCategory.c3Id = ''
  storeCategory.getC2()
}
const selectSecond = () => {
  storeCategory.c3Id = ''
  storeCategory.getC3()
}
</script>

<template>
  <el-card>
    <el-form :inline="true">
      <el-form-item label="一级分类">
        <el-select
          v-model="storeCategory.c1Id"
          placeholder="请选择"
          @change="selectOne"
          :disabled="!props.screen"
        >
          <el-option
            v-for="item in storeCategory.c1Arr"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="二级分类">
        <el-select
          v-model="storeCategory.c2Id"
          placeholder="请选择"
          :disabled="!props.screen"
          @change="selectSecond"
        >
          <el-option
            v-for="item in storeCategory.c2Arr"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="三级分类">
        <el-select
          v-model="storeCategory.c3Id"
          placeholder="请选择"
          :disabled="!props.screen"
        >
          <el-option
            v-for="item in storeCategory.c3Arr"
            :key="item.id"
            :label="item.name"
            :value="item.id"
          />
        </el-select>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<style scoped lang="scss"></style>
